a = 10


def outer():
    a = 5  # 局部变量
    print(f"outer a {a}")  # 5

    def inner1():
        nonlocal a
        a = 20
        print(f"inner 1 a {a}")  # 20

        def inner2():
            nonlocal a
            a = 30
            print(f"inner 2 a {a}")  # 30

        inner2()

    inner1()


outer()
print(f"global a {a}")  # 10
